import '@ant-design/compatible/assets/index.css';
import styles from './index.less';
import React, { useState } from 'react';
import { useRequest } from '@umijs/hooks';
import { useActivate } from 'react-activation';
import router from 'umi/router';
import { Row, Col, message } from 'antd';
import AccidentNumber from './components/AccidentNumber'; // 事故单号检索组件
import PassengerInfo from './components/PassengerInfo'; // 旅客信息检索组件
import { getReviewCount } from './service'
import AuthComponent from '@/components/Authorized/AuthComponent';

const SystemIndex = (props) => {

	// 获取审核案件数量接口
	const { data: getReviewCountD = '', run: getReviewCountR } = useRequest(getReviewCount)

	// 跳转审核页面
	const toCompensationAudit = () => {
    if (AuthComponent.getAuth('compensation.audit.showList')) {
      router.push({
        pathname: '/compensation/CompensationAudit',
        state: { allAudit: true }
      })
    } else {
      message.warning('暂无权限查看');
    }
	}

	 // 缓存
	 useActivate(() => {
    getReviewCountR()
  })

	return (
		<Row style={{ background: 'white', padding: '20px' }}>
			<Col span={15}>
				<AccidentNumber />
				<PassengerInfo />
			</Col>
			<Col span={8} offset={1}>
				<div className={styles.auditNumberBox}>
					<img
						alt=""
						src={require('./components/images/fileIcon.svg')}
					/>
					<div>
						<p>待审核案件数量</p>
						<p onClick={() => toCompensationAudit()} style={{ cursor: 'pointer' }}>{getReviewCountD.count}</p>
					</div>
				</div>

			</Col>
		</Row>
	);
};

export default SystemIndex;
